<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>pygame.PixelArray &mdash; Pygame v1.9.2 documentation</title>
    <link rel="stylesheet" href="../_static/pygame.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.9.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="shortcut icon" href="../_static/pygame.ico"/>
    <link rel="top" title="Pygame v1.9.2 documentation" href="../index.html" />
    <link rel="next" title="pygame.pixelcopy" href="pixelcopy.html" />
    <link rel="prev" title="pygame.Overlay" href="overlay.html" /> 
  </head>
  <body>  

    <div class="document">

  <div class="header">
    <table>
      <tr>
	<td class="logo">
	  <a href="http://www.pygame.org/">
	    <img src="../_static/pygame_tiny.png"/>
	  </a>
	  <h5>pygame documentation</h5>
	</td>
	<td class="pagelinks">
	  <p class="top">
	    ||
	    <a href="http://www.pygame.org/">Pygame Home</a> ||
	    <a href="../index.html">Help Contents</a> ||
	    <a href="../genindex.html">Reference Index</a> ||
	  </p>
	  <p class="bottom">
	    <a href="camera.html">camera</a> || 
	    <a href="cdrom.html">cdrom</a> || 
	    <a href="color.html">Color</a> || 
	    <a href="cursors.html">cursors</a> || 
	    <a href="display.html">display</a> || 
	    <a href="draw.html">draw</a> || 
	    <a href="event.html">event</a> || 
	    <a href="examples.html">examples</a> || 
	    <a href="font.html">font</a> || 
	    <a href="freetype.html">freetype</a> || 
	    <a href="gfxdraw.html">gfxdraw</a> || 
	    <a href="image.html">image</a> || 
	    <a href="joystick.html">joystick</a> || 
	    <a href="key.html">key</a> || 
	    <a href="locals.html">locals</a> || 
	    <a href="mask.html">mask</a> || 
	    <a href="math.html">math</a> || 
	    <a href="midi.html">midi</a> || 
	    <a href="mixer.html">mixer</a> || 
	    <a href="mouse.html">mouse</a> || 
	    <a href="movie.html">movie</a> || 
	    <a href="music.html">music</a> || 
	    <a href="overlay.html">Overlay</a> || 
	    <a href="pixelarray.html">PixelArray</a> || 
	    <a href="pixelcopy.html">pixelcopy</a> || 
	    <a href="pygame.html">pygame</a> || 
	    <a href="rect.html">Rect</a> || 
	    <a href="scrap.html">scrap</a> || 
	    <a href="sndarray.html">sndarray</a> || 
	    <a href="sprite.html">sprite</a> || 
	    <a href="surface.html">Surface</a> || 
	    <a href="surfarray.html">surfarray</a> || 
	    <a href="tests.html">tests</a> || 
	    <a href="time.html">time</a> || 
	    <a href="transform.html">transform</a> || 
	    <a href="pygame.html#module-pygame.version">version</a>
	  </p>
	</td>
      </tr>
    </table>
  </div>

      <div class="documentwrapper">
          <div class="body">
            
  <div class="sectionwrapper">
<div class="section" id="pygame-pixelarray">
<dl class="definition class">
<dt class="title" id="pygame.PixelArray">
<em class="property">class </em><tt class="descclassname">pygame.</tt><tt class="descname">PixelArray</tt><a class="headerlink" href="#pygame.PixelArray" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">pygame object for direct pixel access of surfaces</span></div>
<div class="line"><span class="signature">PixelArray(Surface) -&gt; PixelArray</span></div>
</div>
<table border="1" class="toc docutils">
<colgroup>
<col width="31%" />
<col width="1%" />
<col width="68%" />
</colgroup>
<tbody valign="top">
<tr><td><a class="toc reference external" href="pixelarray.html#pygame.PixelArray.surface">pygame.PixelArray.surface</a></td>
<td>—</td>
<td>Gets the Surface the PixelArray uses.</td>
</tr>
<tr><td><a class="toc reference external" href="pixelarray.html#pygame.PixelArray.itemsize">pygame.PixelArray.itemsize</a></td>
<td>—</td>
<td>Returns the byte size of a pixel array item</td>
</tr>
<tr><td><a class="toc reference external" href="pixelarray.html#pygame.PixelArray.ndim">pygame.PixelArray.ndim</a></td>
<td>—</td>
<td>Returns the number of dimensions.</td>
</tr>
<tr><td><a class="toc reference external" href="pixelarray.html#pygame.PixelArray.shape">pygame.PixelArray.shape</a></td>
<td>—</td>
<td>Returns the array size.</td>
</tr>
<tr><td><a class="toc reference external" href="pixelarray.html#pygame.PixelArray.strides">pygame.PixelArray.strides</a></td>
<td>—</td>
<td>Returns byte offsets for each array dimension.</td>
</tr>
<tr><td><a class="toc reference external" href="pixelarray.html#pygame.PixelArray.make_surface">pygame.PixelArray.make_surface</a></td>
<td>—</td>
<td>Creates a new Surface from the current PixelArray.</td>
</tr>
<tr><td><a class="toc reference external" href="pixelarray.html#pygame.PixelArray.replace">pygame.PixelArray.replace</a></td>
<td>—</td>
<td>Replaces the passed color in the PixelArray with another one.</td>
</tr>
<tr><td><a class="toc reference external" href="pixelarray.html#pygame.PixelArray.extract">pygame.PixelArray.extract</a></td>
<td>—</td>
<td>Extracts the passed color from the PixelArray.</td>
</tr>
<tr><td><a class="toc reference external" href="pixelarray.html#pygame.PixelArray.compare">pygame.PixelArray.compare</a></td>
<td>—</td>
<td>Compares the PixelArray with another one.</td>
</tr>
<tr><td><a class="toc reference external" href="pixelarray.html#pygame.PixelArray.transpose">pygame.PixelArray.transpose</a></td>
<td>—</td>
<td>Exchanges the x and y axis.</td>
</tr>
</tbody>
</table>
<p>The PixelArray wraps a Surface and provides direct access to the
surface&#8217;s pixels. A pixel array can be one or two dimensional.
A two dimensional array, like its surface, is indexed [column, row].
Pixel arrays support slicing, both for returning a subarray or
for assignment. A pixel array sliced on a single column or row
returns a one dimensional pixel array. Arithmetic and other operations
are not supported. A pixel array can be safely assigned to itself.
Finally, pixel arrays export an array struct interface, allowing
them to interact with <a class="tooltip reference internal" href="pixelcopy.html#module-pygame.pixelcopy" title=""><tt class="xref py py-mod docutils literal"><span class="pre">pygame.pixelcopy</span></tt><span class="tooltip-content">pygame module for general pixel array copying</span></a> methods and NumPy
arrays.</p>
<p>A PixelArray pixel item can be assigned a raw integer values, a
<a class="tooltip reference internal" href="color.html#pygame.Color" title=""><tt class="xref py py-class docutils literal"><span class="pre">pygame.Color</span></tt><span class="tooltip-content">pygame object for color representations</span></a> instance, or a (r, g, b[, a]) tuple.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">pxarray</span><span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">]</span> <span class="o">=</span> <span class="mh">0xFF00FF</span>
<span class="n">pxarray</span><span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">]</span> <span class="o">=</span> <span class="n">pygame</span><span class="o">.</span><span class="n">Color</span><span class="p">(</span><span class="mi">255</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">)</span>
<span class="n">pxarray</span><span class="p">[</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="mi">255</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">)</span>
</pre></div>
</div>
<p>However, only a pixel&#8217;s integer value is returned. So, to compare a pixel
to a particular color the color needs to be first mapped using
the <a class="reference internal" href="surface.html#pygame.Surface.map_rgb" title="pygame.Surface.map_rgb"><tt class="xref py py-meth docutils literal"><span class="pre">Surface.map_rgb()</span></tt></a> method of the Surface object for which the
PixelArray was created.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">pxarray</span> <span class="o">=</span> <span class="n">pygame</span><span class="o">.</span><span class="n">PixelArray</span><span class="p">(</span><span class="n">surface</span><span class="p">)</span>
<span class="c"># Check, if the first pixel at the topleft corner is blue</span>
<span class="k">if</span> <span class="n">pxarray</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="n">surface</span><span class="o">.</span><span class="n">map_rgb</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">)):</span>
    <span class="o">...</span>
</pre></div>
</div>
<p>When assigning to a range of of pixels, a non tuple sequence of colors or
a PixelArray can be used as the value. For a sequence, the length must
match the PixelArray width.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">pxarray</span><span class="p">[</span><span class="n">a</span><span class="p">:</span><span class="n">b</span><span class="p">]</span> <span class="o">=</span> <span class="mh">0xFF00FF</span>                   <span class="c"># set all pixels to 0xFF00FF</span>
<span class="n">pxarray</span><span class="p">[</span><span class="n">a</span><span class="p">:</span><span class="n">b</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="mh">0xFF00FF</span><span class="p">,</span> <span class="mh">0xAACCEE</span><span class="p">,</span> <span class="o">...</span> <span class="p">)</span> <span class="c"># first pixel = 0xFF00FF,</span>
                                          <span class="c"># second pixel  = 0xAACCEE, ...</span>
<span class="n">pxarray</span><span class="p">[</span><span class="n">a</span><span class="p">:</span><span class="n">b</span><span class="p">]</span> <span class="o">=</span> <span class="p">[(</span><span class="mi">255</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">),</span> <span class="p">(</span><span class="mi">170</span><span class="p">,</span> <span class="mi">204</span><span class="p">,</span> <span class="mi">238</span><span class="p">),</span> <span class="o">...</span><span class="p">]</span> <span class="c"># same as above</span>
<span class="n">pxarray</span><span class="p">[</span><span class="n">a</span><span class="p">:</span><span class="n">b</span><span class="p">]</span> <span class="o">=</span> <span class="p">[(</span><span class="mi">255</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">),</span> <span class="mh">0xAACCEE</span><span class="p">,</span> <span class="o">...</span><span class="p">]</span>        <span class="c"># same as above</span>
<span class="n">pxarray</span><span class="p">[</span><span class="n">a</span><span class="p">:</span><span class="n">b</span><span class="p">]</span> <span class="o">=</span> <span class="n">otherarray</span><span class="p">[</span><span class="n">x</span><span class="p">:</span><span class="n">y</span><span class="p">]</span>            <span class="c"># slice sizes must match</span>
</pre></div>
</div>
<p>For PixelArray assignment, if the right hand side array has a row length
of 1, then the column is broadcast over the target array&#8217;s rows. An
array of height 1 is broadcast over the target&#8217;s columns, and is equivalent
to assigning a 1D PixelArray.</p>
<p>Subscipt slices can also be used to assign to a rectangular subview of
the target PixelArray.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># Create some new PixelArray objects providing a different view</span>
<span class="c"># of the original array/surface.</span>
<span class="n">newarray</span> <span class="o">=</span> <span class="n">pxarray</span><span class="p">[</span><span class="mi">2</span><span class="p">:</span><span class="mi">4</span><span class="p">,</span> <span class="mi">3</span><span class="p">:</span><span class="mi">5</span><span class="p">]</span>
<span class="n">otherarray</span> <span class="o">=</span> <span class="n">pxarray</span><span class="p">[::</span><span class="mi">2</span><span class="p">,</span> <span class="p">::</span><span class="mi">2</span><span class="p">]</span>
</pre></div>
</div>
<p>Subscript slices can also be used to do fast rectangular pixel manipulations
instead of iterating over the x or y axis. The</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">pxarray</span><span class="p">[::</span><span class="mi">2</span><span class="p">,</span> <span class="p">:]</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>               <span class="c"># Make even columns black.</span>
<span class="n">pxarray</span><span class="p">[::</span><span class="mi">2</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>                  <span class="c"># Same as [::2, :]</span>
</pre></div>
</div>
<p>During its lifetime, the PixelArray locks the surface, thus you explicitly
have to delete it once its not used anymore and the surface should perform
operations in the same scope. A simple <tt class="docutils literal"><span class="pre">:</span></tt> slice index for the column can
be omitted.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">pxarray</span><span class="p">[::</span><span class="mi">2</span><span class="p">,</span> <span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>             <span class="c"># Same as pxarray[::2, :]</span>
<span class="n">pxarray</span><span class="p">[</span><span class="o">...</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="mi">255</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>                <span class="c"># Same as pxarray[:]</span>
</pre></div>
</div>
<p>A note about PixelArray to PixelArray assignment, for arrays with an
item size of 3 (created from 24 bit surfaces) pixel values are translated
from the source to the destinations format. The red, green, and blue
color elements of each pixel are shifted to match the format of the
target surface. For all other pixel sizes no such remapping occurs.
This should change in later Pygame releases, where format conversions
are performed for all pixel sizes. To avoid code breakage when full mapped
copying is implemented it is suggested PixelArray to PixelArray copies be
only between surfaces of identical format.</p>
<p>New in pygame 1.9.2</p>
<blockquote>
<div><ul class="simple">
<li>array struct interface</li>
<li>transpose method</li>
<li>broadcasting for a length 1 dimension</li>
</ul>
</div></blockquote>
<p>Changed in pyame 1.9.2</p>
<blockquote>
<div><ul class="simple">
<li>A 2D PixelArray can have a length 1 dimension.
Only an integer index on a 2D PixelArray returns a 1D array.</li>
<li>For assignment, a tuple can only be a color. Any other sequence type
is a sequence of colors.</li>
</ul>
</div></blockquote>
<dl class="definition attribute">
<dt class="title" id="pygame.PixelArray.surface">
<tt class="descname">surface</tt><a class="headerlink" href="#pygame.PixelArray.surface" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Gets the Surface the PixelArray uses.</span></div>
<div class="line"><span class="signature">surface -&gt; Surface</span></div>
</div>
<p>The Surface the PixelArray was created for.</p>
</dd></dl>

<dl class="definition attribute">
<dt class="title" id="pygame.PixelArray.itemsize">
<tt class="descname">itemsize</tt><a class="headerlink" href="#pygame.PixelArray.itemsize" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Returns the byte size of a pixel array item</span></div>
<div class="line"><span class="signature">itemsize -&gt; int</span></div>
</div>
<p>This is the same as <a class="reference internal" href="surface.html#pygame.Surface.get_bytesize" title="pygame.Surface.get_bytesize"><tt class="xref py py-meth docutils literal"><span class="pre">Surface.get_bytesize()</span></tt></a> for the
pixel array&#8217;s surface.</p>
<p>New in pygame 1.9.2</p>
</dd></dl>

<dl class="definition attribute">
<dt class="title" id="pygame.PixelArray.ndim">
<tt class="descname">ndim</tt><a class="headerlink" href="#pygame.PixelArray.ndim" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Returns the number of dimensions.</span></div>
<div class="line"><span class="signature">ndim -&gt; int</span></div>
</div>
<p>A pixel array can be 1 or 2 dimensional.</p>
<p>New in pygame 1.9.2</p>
</dd></dl>

<dl class="definition attribute">
<dt class="title" id="pygame.PixelArray.shape">
<tt class="descname">shape</tt><a class="headerlink" href="#pygame.PixelArray.shape" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Returns the array size.</span></div>
<div class="line"><span class="signature">shape -&gt; tuple of int&#8217;s</span></div>
</div>
<p>A tuple or length <a class="reference internal" href="#pygame.PixelArray.ndim" title="pygame.PixelArray.ndim"><tt class="xref py py-attr docutils literal"><span class="pre">ndim</span></tt></a> giving the length of each
dimension. Analogous to <a class="reference internal" href="surface.html#pygame.Surface.get_size" title="pygame.Surface.get_size"><tt class="xref py py-meth docutils literal"><span class="pre">Surface.get_size()</span></tt></a>.</p>
<p>New in pygame 1.9.2</p>
</dd></dl>

<dl class="definition attribute">
<dt class="title" id="pygame.PixelArray.strides">
<tt class="descname">strides</tt><a class="headerlink" href="#pygame.PixelArray.strides" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Returns byte offsets for each array dimension.</span></div>
<div class="line"><span class="signature">strides -&gt; tuple of int&#8217;s</span></div>
</div>
<p>A tuple or length <a class="reference internal" href="#pygame.PixelArray.ndim" title="pygame.PixelArray.ndim"><tt class="xref py py-attr docutils literal"><span class="pre">ndim</span></tt></a> byte counts. When a stride is
multiplied by the corresponding index it gives the offset
of that index from the start of the array. A stride is negative
for an array that has is inverted (has a negative step).</p>
<p>New in pygame 1.9.2</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.PixelArray.make_surface">
<tt class="descname">make_surface</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.PixelArray.make_surface" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Creates a new Surface from the current PixelArray.</span></div>
<div class="line"><span class="signature">make_surface() -&gt; Surface</span></div>
</div>
<p>Creates a new Surface from the current PixelArray. Depending on the
current PixelArray the size, pixel order etc. will be different from the
original Surface.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># Create a new surface flipped around the vertical axis.</span>
<span class="n">sf</span> <span class="o">=</span> <span class="n">pxarray</span><span class="p">[:,::</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">make_surface</span> <span class="p">()</span>
</pre></div>
</div>
<p>New in pygame 1.8.1.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.PixelArray.replace">
<tt class="descname">replace</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.PixelArray.replace" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Replaces the passed color in the PixelArray with another one.</span></div>
<div class="line"><span class="signature">replace(color, repcolor, distance=0, weights=(0.299, 0.587, 0.114)) -&gt; None</span></div>
</div>
<p>Replaces the pixels with the passed color in the PixelArray by changing
them them to the passed replacement color.</p>
<p>It uses a simple weighted euclidian distance formula to calculate the
distance between the colors. The distance space ranges from 0.0 to 1.0
and is used as threshold for the color detection. This causes the
replacement to take pixels with a similar, but not exactly identical
color, into account as well.</p>
<p>This is an in place operation that directly affects the pixels of the
PixelArray.</p>
<p>New in pygame 1.8.1.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.PixelArray.extract">
<tt class="descname">extract</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.PixelArray.extract" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Extracts the passed color from the PixelArray.</span></div>
<div class="line"><span class="signature">extract(color, distance=0, weights=(0.299, 0.587, 0.114)) -&gt; PixelArray</span></div>
</div>
<p>Extracts the passed color by changing all matching pixels to white, while
non-matching pixels are changed to black. This returns a new PixelArray
with the black/white color mask.</p>
<p>It uses a simple weighted euclidian distance formula to calculate the
distance between the colors. The distance space ranges from 0.0 to 1.0
and is used as threshold for the color detection. This causes the
extraction to take pixels with a similar, but not exactly identical
color, into account as well.</p>
<p>New in pygame 1.8.1.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.PixelArray.compare">
<tt class="descname">compare</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.PixelArray.compare" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Compares the PixelArray with another one.</span></div>
<div class="line"><span class="signature">compare(array, distance=0, weights=(0.299, 0.587, 0.114)) -&gt; PixelArray</span></div>
</div>
<p>Compares the contents of the PixelArray with those from the passed
PixelArray. It returns a new PixelArray with a black/white color mask
that indicates the differences (white) of both arrays. Both PixelArray
objects must have indentical bit depths and dimensions.</p>
<p>It uses a simple weighted euclidian distance formula to calculate the
distance between the colors. The distance space ranges from 0.0 to 1.0
and is used as threshold for the color detection. This causes the
comparision to mark pixels with a similar, but not exactly identical
color, as black.</p>
<p>New in pygame 1.8.1.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.PixelArray.transpose">
<tt class="descname">transpose</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.PixelArray.transpose" title="Permalink to this definition">¶</a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Exchanges the x and y axis.</span></div>
<div class="line"><span class="signature">transpose() -&gt; PixelArray</span></div>
</div>
<p>This method returns a new view of the pixel array with the rows and
columns swapped. So for a (w, h) sized array a (h, w) slice is returned.
If an array is one dimensional, then a length 1 x dimension is added,
resulting in a 2D pixel array.</p>
<p>New in pygame 1.9.2</p>
</dd></dl>

</dd></dl>

</div>

  </div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="pixelcopy.html" title="pygame.pixelcopy"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="overlay.html" title="pygame.Overlay"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">Pygame v1.9.2 documentation</a> &raquo;</li>
    <script type="text/javascript" src="jquery.plugin.docscomments.js"></script>

      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2011, Pygame Developers.
    </div>
  </body>
</html>